<template>
    <div class="wy-main business-car-manage">
     <a-row class="wy-main-title">
       <a-col :span="24">
        <p class="title-p">
          <a-divider class="title-vertical"  type="vertical" />
          <span class="title-span" >企业认证审核</span>
          <a-divider class="title-divider"  />
        </p>
      </a-col>
   </a-row>
     <div class="my-main-cont">
         <a-input  placeholder="请输入企业名称" v-model="company" style="width: 200px"/>
         <a-button type="primary" style="margin-left: 10px;" @click="gettenderinginfo()">查询</a-button>
         <a-button style="margin-left: 10px;" @click="react">重置</a-button>
         <a-button class="title-button" type="primary" style="float: right" @click="seeAllInfo()">批量审核</a-button>
          <div class="wei_company wei_enterprise_company">
         <a-table :columns="columns" :rowKey="record => record.username" :dataSource="data" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange" :pagination="pagination" :loading="loading" style="margin-top: 20px" >
           <span slot="name" slot-scope="text1">
             <span>{{text1.address1}}--→{{text1.address2}}</span>
           </span>
           <span slot="companyCreateTime" slot-scope="text, record">
                <span v-if="!!record.companyCreateTime">{{record.companyCreateTime.split(" ")[0]}}</span>
            </span>
           <span slot="createTime" slot-scope="text, record">
                <span v-if="!!record.createTime">{{record.createTime.split(" ")[0]}}</span>
              </span>
             <span slot="operation" slot-scope="text, record">
                <a href="javascript:;" class="wei_warning" v-if="record.attestationStatus==110" @click="seeInfo(record)">待认证</a>
                <a href="javascript:;" class="wei_primary" v-if="record.attestationStatus==111" @click="seeInfo(record)">认证通过</a>
                <a href="javascript:;" class="wei_danger" v-if="record.attestationStatus==112" @click="seeInfo(record)">认证失败</a>
             </span>
         </a-table>
         </div>
<!--           <div style="margin-top: -50px">
            <a-button @click="delAll">删除所选</a-button>
          </div> -->
          <a-modal title="企业认证审核" :visible="visible"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
           <publish-add v-if="visible" @cancel="handleCancel" :datail='datail'></publish-add>
          </a-modal>
          <a-modal title="企业认证审核" :visible="visibleAll"  @cancel="handleCancel"  width="900px" :maskClosable='false' :footer="null" >
           <publish-add-all v-if="visibleAll" @cancel="handleCancel" :datailAll='datailAll'></publish-add-all>
          </a-modal>
     </div>
     
    </div>
</template>
<script>
import publishAdd  from './Publish'
import publishAddAll  from './PublishAll'
const columns = [{
    title: '企业名称',
    dataIndex: 'company',
    key: 'company'
  
  },{
    title: '法人代表姓名',
    dataIndex: 'legalPerson',
    key: 'legalPerson'
  
  },{
    title: '统一社会信用代码',
    dataIndex: 'socialCode',
    key: 'socialCode'
  },{
    title: '企业成立日期',
    key: 'companyCreateTime',
    dataIndex: 'companyCreateTime',
    scopedSlots: {
      customRender: 'companyCreateTime'
    },
  },{
    title: '企业注册地址',
    key: 'companyAddress',
    dataIndex: 'companyAddress',
  },{
    title: '提交日期',
    key: 'createTime',
    dataIndex: 'createTime',
    scopedSlots: {
      customRender: 'createTime'
    },
  },{
      title: '操作',
      key: 'operation',
      scopedSlots: {
        customRender: 'operation'
      },
    }];
// const rowSelection = {
//   onChange: (selectedRowKeys, selectedRows) => {
//     console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
// //   },
// //   onSelect: (record, selected, selectedRows) => {
// //     console.log(record, selected, selectedRows);
// //   },
// //   onSelectAll: (selected, selectedRows, changeRows) => {
// //     console.log(selected, selectedRows, changeRows);
//   },
// };
export default {
    
    data() {
        return {
         datail: {},
         datailAll:{},
         company: '',
         data:[],
         visible: false,
         visibleAll:false,
         loading: false,
         type:2,
         columns,
         // rowSelection,
          selectedRowKeys: [],
          pagination: {
          pageSizeOptions: ['10', '20', '30', '40', '100'],
          defaultCurrent: 1,
          defaultPageSize: 10,
          total:10,
          showSizeChanger: true,
          showTotal: (total, range) => `共 ${total} 条记录`
        },
        }
    }, 
    created() {
      this.gettenderinginfo()
    },
    components: {
      publishAdd,
      publishAddAll
    },
    methods: {


      // 审核线路信息
      seeInfo(data){
        this.visible = true
        this.datail = data
      },
      seeAllInfo(){
        if(this.selectedRowKeys.length){
            this.visibleAll = true;
            let logIds = [];
           for(var i=0;i<this.selectedRowKeys.length;i++){
            logIds.push({"username":this.selectedRowKeys[i]})
           }
            this.datailAll = logIds;
          }else{
            this.$message.success('请选择需要审核的企业!')
          }
      
      },
      //关闭弹框

      handleCancel(){
      this.visible = false
      this.visibleAll = false
      this.gettenderinginfo();
      this.selectedRowKeys=[];
      },
      //删除
      delAll() {
        this.$confirm({
          title: '确定删除所选中的记录？',
          content: '当您点击确定按钮后，这些记录将会被彻底删除',
          centered: true
        })
      },
      onSelectChange (selectedRowKeys) {
          console.log('selectedRowKeys changed: ', selectedRowKeys);
          this.selectedRowKeys = selectedRowKeys
        },
      //审核
            // 删除单条信息
      delDriver(data){
        console.log(data)
        let that = this
        this.$confirm({
          title: '确定删除所选中的记录?',
          content: '当您点击确定按钮后，这些记录将会被彻底删除',
          centered: true,
          onOk () {
            let logIds = []
            logIds.push(data.userId)
            that.$delete('/info/logisticsTenderee/' + logIds.join(',')).then(() => {
              that.$message.success('删除成功')
              that.selectedRowKeys = []
              that.gettenderinginfo()
            })
          },
          onCancel () {
            that.selectedRowKeys = []
          }
        })
      },
    
      //重置
      react() {
        this.company = ''
        this.defaultCurrent = 1
        this.gettenderinginfo()
      },
      // 获取招标信息
      gettenderinginfo(params={}){
        this.loading = true
        params.company = this.company
        params.type = this.type
        params.pageSize = this.pagination.defaultPageSize
        params.pageNum = this.pagination.defaultCurrent
        params.attestationStatus = 109//与后台协定，后台查询非109状态的
        this.$get('/user/',params).then((r) => {
          this.loading = false
          console.log(r)
          this.data = r.data.rows
          this.pagination.total = r.data.total
        })
      },
      // 表格排序 分页 筛选事件
      handleTableChange(pagination, filters, sorter) {
         this.pagination.defaultPageSize = pagination.pageSize
         this.pagination.defaultCurrent  = pagination.current
         this.gettenderinginfo();
        // this.getcarSource({
        //   ...this.queryParams
        // })
      },

    }
}
</script>
<style lang="less">

</style>
